package com.example.boot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.boot.enums.MsgSignFlagEnum;
import com.example.boot.mapper.MxGroupChatMsgDao;
import com.example.boot.mapper.MxGroupPersonnelDao;
import com.example.boot.pojo.MxGroupChatMsgEntity;
import com.example.boot.pojo.MxGroupPersonnelEntity;
import com.example.boot.service.MxGroupPersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;


@Service("mxGroupPersonnelService")
public class MxGroupPersonnelServiceImpl extends ServiceImpl<MxGroupPersonnelDao, MxGroupPersonnelEntity> implements MxGroupPersonnelService {
    @Autowired
    private MxGroupPersonnelDao mxGroupPersonnelDao;
    @Autowired
    private MxGroupChatMsgDao mxGroupChatMsgDao;
    @Override
    public List<MxGroupPersonnelEntity> getGroupPersonnellist(Long groupId) {
        LambdaQueryWrapper<MxGroupPersonnelEntity> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(MxGroupPersonnelEntity::getGroupId,groupId);
        return mxGroupPersonnelDao.selectList(lambdaQueryWrapper);
    }
    @Override
    public Long saveMsg(MxGroupChatMsgEntity msgDB) {



        msgDB.setCreateTime(new Date());
        msgDB.setSignFlag(MsgSignFlagEnum.unsign.type);


        mxGroupChatMsgDao.insert(msgDB);

        return msgDB.getId();
    }

    @Override
    public List<Map<String, Object>> getGroupPersonnel(MxGroupPersonnelEntity groupPersonnelEntity) {
        return    mxGroupPersonnelDao.getGroupPersonnel(groupPersonnelEntity);
    }
}